﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Popup.Master" AutoEventWireup="true"
    CodeBehind="POSBusinessPartnersList.aspx.cs" Inherits="SapB1WebPOS.POSBusinessPartnersList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PopupContent" runat="server">
    <script type="text/javascript">
        var grid;
        function onChange(arg) {
            var selectedRows = this.select();
            var selectedDataItems = [];
            for (var i = 0; i < selectedRows.length; i++) {
                var dataItem = this.dataItem(selectedRows[i]);
                selectedDataItems.push(dataItem);
            }
            if (selectedDataItems.length > 0) {
                parent.ChooseCustomer(selectedDataItems[0].ObjCode, selectedDataItems[0].ObjName);
            }
        }
        $(document).ready(function () {
            grid = $("#grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            type: "GET",
                            url: "POSBusinessPartnersList.aspx/GetCustomerList",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json"
                        },
                        serverPaging: true,
                        serverSorting: true,
                        serverFiltering: true
                    },
                    pageSize: 1000,
                    type: "json",
                    schema: {
                        data: function (response) {
                            if (response.d != null) {
                                var data = response.d;
                                return JSON.parse(data);
                            }
                        },
                        total: function (response) {
                            return JSON.parse(response.d).length;
                        },
                        model: {
                            id: "ObjCode",
                            fields: {
                                ObjCode: { type: "string" },
                                ObjName: { type: "string" }
                            }
                        }
                    }
                },
                change: onChange,
                sortable: true,
                pageable: {
                    refresh: true
                },
                filterable: true,
                reorderable: true,
                resizable: true,
                height: 450,
                selectable: "row",
                batch: true,
                columns: [{ field: "ObjCode", title: "Customer Code", width: 170 },
                            { field: "ObjName", title: "Customer Name" }
                            ]
            }).data("kendoGrid");
        });
    </script>
    <div id="grid">
    </div>
</asp:Content>
